package com.vm.myview;

import javax.swing.text.html.ImageView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.vm.commons.StringUtil;
import com.vm.commons.VMConst;
import com.vm.utils.MyDisplayImageOptions;
import com.wwtscapp.apk.R;

import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.widget.RemoteViews;

@SuppressLint("NewApi")
public class NotificationView {
	ImageView notify_imageLog;

	public NotificationView(Context context, String imageurl, String softname,
			String text, String tickertext, String filepath) {
		NotificationManager manager = (NotificationManager) context
				.getSystemService(Context.NOTIFICATION_SERVICE);
		Notification myNotify = new Notification();
		myNotify.icon = R.drawable.logo2;
		myNotify.tickerText = tickertext;
		myNotify.when = System.currentTimeMillis();
		myNotify.flags = Notification.FLAG_SHOW_LIGHTS;
		RemoteViews rv = new RemoteViews(context.getPackageName(),
				R.layout.notify_view);
		// Bitmap bitmap = null;
		// bitmap = BitmapFactory.getBitmapFromURL(VMConst.URL + imageurl);
		// rv.setImageViewBitmap(R.id.notify_imageLog, bitmap);
		// myNotify.largeIcon = bitmap

		// myNotify.contentView.setImageViewUri(R.id.notify_imageLog,
		// VMConst.URL + imageurl);

		rv.setTextViewText(R.id.notify_name, softname);
		rv.setTextViewText(R.id.notify_msg, text);
		rv.setTextViewText(R.id.notify_time, StringUtil.getDate(5));
		myNotify.contentView = rv;

		// ImageLoader.getInstance().displayImage(VMConst.URL+imageurl,rv.setim
		// );
		Bitmap bitmap = ImageLoader.getInstance().loadImageSync(
				VMConst.URL + imageurl, MyDisplayImageOptions.getInstance());
		myNotify.contentView.setImageViewBitmap(R.id.notify_imageLog, bitmap);
		Intent intent = new Intent(Intent.ACTION_VIEW);
		intent.setDataAndType(Uri.parse("file://" + filepath),
				"application/vnd.android.package-archive");
		PendingIntent contentIntent = PendingIntent.getActivity(context, 1,
				intent, 1);
		myNotify.contentIntent = contentIntent;
		manager.notify(100, myNotify);
	}

	public static void main(String[] args) {
		Bitmap bitmap = null;
		bitmap = ImageLoader.getInstance().loadImageSync(
				VMConst.URL + "0b4841d4-0a5e-4f19-be8d-cd2355451a8c");
		// bitmap = BitmapFactory.getBitmapFromURL(VMConst.URL +
		// "0b4841d4-0a5e-4f19-be8d-cd2355451a8c");
		System.out.println(bitmap);
	}
}